package org.jshand.homework.api;

import java.util.Objects;

/**
 * @author 金山
 * 项目：javase
 * site: https://blog.fulfill.com.cn
 * 描述
 * @data 2024/10/259:13
 */
public class Student {
    private String id;
    private String name;

    private String sage;


    public Student() {
    }

    public Student(String id, String name) {
        this.id = id;
        this.name = name;
    }

    public Student(String id, String name, String sage) {
        this.id = id;
        this.name = name;
        this.sage = sage;
    }

    public void incrementAge(){
        int intAge = Integer.parseInt(sage);
        intAge++;


        sage = String.valueOf(intAge);
    }




    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    // @Override
    // public boolean equals(Object o) {
    //     if (this == o) return true;
    //     if (o == null || getClass() != o.getClass()) return false;
    //
    //     Student student = (Student) o;
    //
    //     if (id != null ? !id.equals(student.id) : student.id != null) return false;
    //     return name != null ? name.equals(student.name) : student.name == null;
    // }


    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Student student = (Student) o;
        return Objects.equals(id, student.id) && Objects.equals(name, student.name);
    }

    @Override
    public int hashCode() {
        int result = id != null ? id.hashCode() : 0;
        result = 31 * result + (name != null ? name.hashCode() : 0);
        return result;
    }

    @Override
    public String toString() {
        return "Student{" +
                "id='" + id + '\'' +
                ", name='" + name + '\'' +
                ", sage='" + sage + '\'' +
                '}';
    }
}
